package com.qi.spzx.manager.mapper;

import com.qi.spzx.model.entity.product.ProductSku;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @Description TODO
 * @Author dingchunlin
 * @Date 2024/2/23 19:15
 * @Version 1.0.0
 */
@Mapper
public interface ProductSkuMapper {

    @Select("select * from product_sku where is_deleted = 1 and product_id = #{productId};")
    List<ProductSku> selectByProductId(Long productId);

    @Insert("insert into product_sku value(null,#{skuCode},#{skuName},#{productId},#{thumbImg},#{salePrice},#{marketPrice}" +
            ",#{costPrice},#{stockNum},#{saleNum},#{skuSpec},#{weight},#{volume},#{status},now(),now(),1)")
    void save(ProductSku productSku);

    void updateById(ProductSku productSku);


    @Update("update product_sku set is_deleted = 0 ,update_time = now() where product_id = #{productId}")
    void deleteByProductId(Long id);
}
